package org.come.Jpanel;
import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.util.Map;

import javax.swing.*;

import com.gl.util.Xy2Util;
import com.tool.btn.GoodPanelBtn;
import com.tool.role.RoleData;
import org.apache.commons.lang.StringUtils;
import org.come.Frame.Teststatejframe;
import org.come.Frame.ZhuFrame;
import org.come.bean.ConfigureBean;
import org.come.bean.LoginResult;
import org.come.model.Configure;
import org.come.mouslisten.PointChangeMouslisten;
import org.come.mouslisten.WLLMouslisten;
import org.come.until.*;
import org.soaring.btn.CharacterBtn;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.JpanelOnJalbelBtn;
import com.tool.btn.SpecificBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;


/**
 * 人物状态窗口类
 *
 * @author Administrator
 */

public class TeststateJpanel extends JPanel implements MouseListener {

    private final long serialVersionUID = 1L;
    private JLabel[] lianghaos;
    private Teststatejframe teststatejframe;
    private int expsize;// 放置飞升经验条的长度
    private JLabel label;
    private int level; // 等级
    private JLabel labrolename,// 名字输入框
            labappeleid // 角色Id
            , labappellation // 称谓输入框
            , labrace// 种族输入框
            , labgangs// 帮派输入框
            , labprestige// 声望输入框
            , labrecord// 战绩输入框
            , labrisegrade// 飞升等级
            , labrolelevel// 等级输入框
            , labHP, labMP, labAP, labSP, labCP, labEXP, labEXPImg// HP、MP、AP、SP、禅定、EXP
            , strip//升级经验背景条
            , labrootbone// 根骨输入框
            , labintelligence// 灵性输入框
            , labpower// 力量输入框
            , labspeed// 敏捷输入框
            , labability // 定力输入框
            , labpointnumber// 可分配点数输入框
            , labrolehead;// 人物头像
    private JpanelOnJalbelBtn btnmount,// 灵宝按钮
            wingBtn,// 翅膀按钮
            btnsure,// 确认加点按钮
            btnroleresistance// 角色抗性按钮
            , btndskills// 技能查看按钮
            , btnstall// 在线摆摊按钮
            , btnset// 套装
            , btnset1// 坐骑
            , btnSevenTwo // 七十二变
            , avatarSwitchBtn; // 头像切换按钮

    private CharacterBtn nameBtn // 姓名按钮
            ,
            idBtn // id按钮
            , labappellationBtn // 称谓按钮
            , attributeBtn // 切换属性按钮
            , transformationBtn;// 转换

    private CharacterBtn[] dians = new CharacterBtn[10];
    private SpecificBtn btnXxzb;// 形象装扮按钮
    private JpanelOnJalbelBtn btnlock1;
    private JLabel labroleheadFrame;
    private JLabel labroleheadBlack;


    /**
     * 飞升后人物面板
     *
     * @param teststatejframe
     * @throws Exception
     */
    public TeststateJpanel(Teststatejframe teststatejframe) throws Exception {
        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(1));
        //翅膀开关
        String cbkg = configure.getCbgnkg();
        if (MyIsif.getStyle().equals("水墨UI")) {
            this.setPreferredSize(new Dimension(359, 450));
            this.setOpaque(false);
            this.setLayout(null);

            // 关闭按钮事件
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 0);
            offBtn.setBounds(362 - 40, 10, 25, 25);
            this.add(offBtn);

//            // 形象装扮按钮
//            btnXxzb = new SpecificBtn("skin/8100226/button/49.png", 1, UIUtils.COLOR_BTNTEXT, "形象装扮", 1);
//            btnXxzb.setBounds(70, 164, 68, 17);
//            this.add(btnXxzb);

            for (int i = 0; i < dians.length; i++) {
                if (i % 2 == 0) {
                    dians[i] = new CharacterBtn("skin/8100226/button/12.png", 1, 10 + i);
                } else {
                    dians[i] = new CharacterBtn("skin/8100226/button/11.png", 1, 10 + i);
                }
                dians[i].setBounds(310 + i % 2 * 14, 209 + i / 2 * 24, 12, 16);
                dians[i].addMouseListener(new PointChangeMouslisten(i));
                this.add(dians[i]);
            }

            // 名字
            labrolename = new JLabel();
            labrolename.setBounds(215, 32, 120, 15);
            labrolename.setForeground(Color.WHITE);
            labrolename.setFont(new Font("微软雅黑", 1, 14));
            this.add(labrolename);

            // 角色Id
            labappeleid = new JLabel();
            labappeleid.setBounds(215, 58, 120, 15);
            labappeleid.setForeground(Color.WHITE);
//            labappeleid.setForeground(new Color(184, 164, 72));
            labappeleid.setFont(new Font("宋体", 0, 14));
            this.add(labappeleid);

            // 帮派
            labgangs = new JLabel();
            labgangs.setBounds(215, 80, 120, 15);
            labgangs.setForeground(Color.WHITE);
            labgangs.setFont(new Font("微软雅黑", 1, 14));
            this.add(labgangs);

            // 声望
            labprestige = new JLabel();
            labprestige.setBounds(215, 105, 120, 15);
            labprestige.setForeground(Color.WHITE);
            labprestige.setFont(new Font("微软雅黑", 1, 14));
            this.add(labprestige);

            // 战绩
            labrecord = new JLabel();
            labrecord.setBounds(215, 128, 120, 15);
            labrecord.setForeground(Color.WHITE);
            labrecord.setFont(new Font("微软雅黑", 1, 14));
            this.add(labrecord);

            // 称谓
            labappellation = new JLabel();
            labappellation.setBounds(215, 151, 120, 18);
            labappellation.setForeground(Color.WHITE);
            labappellation.setFont(new Font("宋体", 1, 14));
            this.add(labappellation);

            // 种族
            labrace = new JLabel();
            labrace.setBounds(48, 145, 110, 16);
            labrace.setForeground(new Color(8, 4, 8));
            labrace.setFont(UIUtils.TEXT_HY17);
            labrace.setHorizontalAlignment(SwingConstants.CENTER);
            this.add(labrace);

            // 飞升等级
            labrisegrade = new JLabel();
            labrisegrade.setBounds(91, 153, 55, 15);
            labrisegrade.setForeground(Color.WHITE);
            labrisegrade.setFont(new Font("微软雅黑", 1, 14));
            this.add(labrisegrade);

            // 级别
            labrolelevel = new JLabel();
            labrolelevel.setBounds(80, 188, 80, 15);
            labrolelevel.setForeground(Color.WHITE);
            labrolelevel.setFont(new Font("微软雅黑", 1, 14));
            this.add(labrolelevel);

            // HP
            labHP = new JLabel();
            labHP.setBounds(80, 212, 125, 15);
            labHP.setForeground(Color.WHITE);
            labHP.setFont(new Font("微软雅黑", 1, 14));
            this.add(labHP);

            // MP
            labMP = new JLabel();
            labMP.setBounds(80, 236, 125, 15);
            labMP.setForeground(Color.WHITE);
            labMP.setFont(new Font("微软雅黑", 1, 14));
            this.add(labMP);

            // AP
            labAP = new JLabel();
            labAP.setBounds(80, 260, 125, 15);
            labAP.setForeground(Color.WHITE);
            labAP.setFont(new Font("微软雅黑", 1, 14));
            this.add(labAP);

            // SP
            labSP = new JLabel();
            labSP.setBounds(80, 284, 125, 15);
            labSP.setForeground(Color.WHITE);
            labSP.setFont(new Font("微软雅黑", 1, 14));
            this.add(labSP);

            // 禅定
            labCP = new JLabel();
            labCP.setBounds(80, 309, 125, 15);
            labCP.setForeground(Color.WHITE);
            labCP.setFont(new Font("微软雅黑", 1, 14));
            this.add(labCP);

            // EXP
            labEXP = new JLabel();
            labEXP.setBounds(91, 307, 125, 15);
            labEXP.setForeground(Color.WHITE);
            labEXP.setFont(new Font("微软雅黑", 1, 12));
            this.add(labEXP);

            // 根骨
            labrootbone = new JLabel();
            labrootbone.setBounds(266, 210, 61, 15);
            labrootbone.setForeground(Color.WHITE);
            labrootbone.setFont(new Font("微软雅黑", 1, 14));
            this.add(labrootbone);

            // 灵性
            labintelligence = new JLabel();
            labintelligence.setBounds(266, 234, 61, 15);
            labintelligence.setForeground(Color.WHITE);
            labintelligence.setFont(new Font("微软雅黑", 1, 14));
            this.add(labintelligence);

            // 力量
            labpower = new JLabel();
            labpower.setBounds(266, 258, 61, 15);
            labpower.setForeground(Color.WHITE);
            labpower.setFont(new Font("微软雅黑", 1, 14));
            this.add(labpower);

            // 敏捷
            labspeed = new JLabel();
            labspeed.setBounds(266, 282, 61, 15);
            labspeed.setForeground(Color.WHITE);
            labspeed.setFont(new Font("微软雅黑", 1, 14));
            this.add(labspeed);

            // 定力
            labability = new JLabel("0");
            labability.setBounds(266, 306, 61, 15);
            labability.setForeground(Color.WHITE);
            labability.setFont(new Font("微软雅黑", 1, 14));
            this.add(labability);

            // 可分配点数
            labpointnumber = new JLabel();
            labpointnumber.setBounds(292, 188, 41, 15);
            labpointnumber.setForeground(Color.WHITE);
            labpointnumber.setFont(new Font("微软雅黑", 1, 14));
            this.add(labpointnumber);

            // 人物头像框
            // labroleheadFrame = new JLabel();
            // labroleheadFrame.setBounds(36, 30, 87, 112);
            // labroleheadFrame.setIcon(new
            // ImageIcon("inkImg/hongmu/soaring/头像框w87,h122px.png"));
            // this.add(labroleheadFrame);

            // 人物头像
            labrolehead = new JLabel();
            labrolehead.setBounds(67, 39, 75, 100);
            this.add(labrolehead);
            // 初始化时加载保存的头像
            loadSavedAvatar();

            // 添加头像切换按钮
            avatarSwitchBtn = new JpanelOnJalbelBtn("inkImg/background/qiehuantouxiang.png", 1, UIUtils.COLOR_WHITE2, 199, "", this);
            avatarSwitchBtn.setBounds(40, 27, 23, 122);
            avatarSwitchBtn.setOpaque(false);
            avatarSwitchBtn.setLayout(null);
            this.setComponentZOrder(avatarSwitchBtn, 0);
            this.add(avatarSwitchBtn);


            if (cbkg.equals("开")) {

                // 七十二变
                btnSevenTwo = new JpanelOnJalbelBtn("skin/8100226/newbutton/B21.png", 1, UIUtils.COLOR_WHITE2, 8, "七十二变", this);
                btnSevenTwo.setBounds(35, 372, 79, 24);
                this.add(btnSevenTwo);

                // 灵 宝
                btnmount = new JpanelOnJalbelBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, 1, "灵宝", this);
                btnmount.setBounds(130, 372, 59, 24);
                this.add(btnmount);
                // 角色抗性
                btnroleresistance = new JpanelOnJalbelBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, 2, "抗性", this);
                btnroleresistance.setBounds(205, 372, 59, 24);
                this.add(btnroleresistance);

                // 翅膀
                wingBtn = new JpanelOnJalbelBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, 9, "翅膀", this);
                wingBtn.setBounds(280, 372, 59, 24);
                this.add(wingBtn);

            } else {

                // 七十二变
                btnSevenTwo = new JpanelOnJalbelBtn("skin/8100226/newbutton/B22.png", 1, UIUtils.COLOR_WHITE2, 8, "七十二变", this);
                btnSevenTwo.setBounds(45, 372, 99, 24);
                this.add(btnSevenTwo);

                // 灵 宝
                btnmount = new JpanelOnJalbelBtn("skin/8100226/newbutton/B21.png", 1, UIUtils.COLOR_WHITE2, 1, "灵 宝", this);
                btnmount.setBounds(160, 372, 79, 24);
                this.add(btnmount);

                // 角色抗性
                btnroleresistance = new JpanelOnJalbelBtn("skin/8100226/newbutton/B21.png", 1, UIUtils.COLOR_WHITE2, 2, "抗 性", this);
                btnroleresistance.setBounds(255, 372, 79, 24);
                this.add(btnroleresistance);
            }

            if (configure.getXpgnkg().equals("开")) {


                // 技能查看
                btndskills = new JpanelOnJalbelBtn("skin/8100226/newbutton/B21.png", 1, UIUtils.COLOR_WHITE2, 4, "人物技能", this);
                btndskills.setBounds(35, 405, 79, 24);
                this.add(btndskills);


                // 坐 骑
                btnset1 = new JpanelOnJalbelBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, 17, "坐骑", this);
                btnset1.setBounds(130, 405, 59, 24);
                this.add(btnset1);


                // 作 坊
                btnset = new JpanelOnJalbelBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, 7, "作坊", this);
                btnset.setBounds(205, 405, 59, 24);
                this.add(btnset);


                btnlock1 = new JpanelOnJalbelBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, 16, "星盘", this);
                btnlock1.setBounds(280, 405, 59, 24);
                this.add(btnlock1);

            } else {

                // 技能查看
                btndskills = new JpanelOnJalbelBtn("skin/8100226/newbutton/B22.png", 1, UIUtils.COLOR_WHITE2, 4, "人物技能", this);
                btndskills.setBounds(45, 405, 99, 24);
                this.add(btndskills);


                // 坐 骑
                btnset1 = new JpanelOnJalbelBtn("skin/8100226/newbutton/B21.png", 1, UIUtils.COLOR_WHITE2, 17, "坐 骑", this);
                btnset1.setBounds(160, 405, 79, 24);
                this.add(btnset1);


                // 作 坊
                btnset = new JpanelOnJalbelBtn("skin/8100226/newbutton/B21.png", 1, UIUtils.COLOR_WHITE2, 7, "作 坊", this);
                btnset.setBounds(255, 405, 79, 24);
                this.add(btnset);


            }


//            // 在线摆摊
//            btnroleresistance = new JpanelOnJalbelBtn(imageMap.getImgMap().get("B22"),"B22", 1, UIUtils.COLOR_WHITE2, 5, "在线摆摊", this);
//            btnroleresistance.setBounds(244, 405, 99, 24);
//            this.add(btnroleresistance);


            // 名字按钮
            nameBtn = new CharacterBtn("skin/8100226/newbutton/B30.png", 1, UIUtils.COLOR_BTNTEXT, "名字", 1);
            nameBtn.setBounds(173, 31, 34, 17);
            this.add(nameBtn);
            // id按钮
            idBtn = new CharacterBtn("skin/8100226/newbutton/B30.png", 1, UIUtils.COLOR_BTNTEXT, "ID", 2);
            idBtn.setBounds(173, 55, 34, 17);
            this.add(idBtn);
            // 称谓按钮
            labappellationBtn = new CharacterBtn("skin/8100226/newbutton/B30.png", 1, UIUtils.COLOR_BTNTEXT, "称谓", 3);
            labappellationBtn.setBounds(173, 151, 34, 17);
            this.add(labappellationBtn);

            // 切换属性
            attributeBtn = new CharacterBtn("skin/8100226/newbutton/B32.png", 1, UIUtils.COLOR_BTNTEXT, "切属性", 4);
            attributeBtn.setBounds(165, 186, 51, 17);
            this.add(attributeBtn);

            // 转换
            transformationBtn = new CharacterBtn("skin/8100226/newbutton/B30.png", 1, UIUtils.COLOR_BTNTEXT, "转换", 5);
            transformationBtn.setBounds(178, 330, 34, 17);
            this.add(transformationBtn);

            // 确认加点
            btnsure = new JpanelOnJalbelBtn("skin/8100226/newbutton/B32.png", 1, UIUtils.COLOR_BTNTEXT, 0, "确认加点", this);
//           btnsure.setForeground(Color.WHITE);
            btnsure.setBounds(160, 405, 51, 17);
            this.add(btnsure);
        } else {
            this.setPreferredSize(new Dimension(335, 477));
            this.setOpaque(false);
            this.setLayout(null);

            // 关闭按钮事件
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/hongmu/1/s74.png", 1, 0);
            offBtn.setBounds(335 - 25, 0, 23, 23);
            this.add(offBtn);

            for (int i = 0; i < dians.length; i++) {
                if (i % 2 == 0) {
                    dians[i] = new CharacterBtn("inkImg/hongmu/2/26_png.button.btn_left.png", 1, 10 + i);
                } else {
                    dians[i] = new CharacterBtn("inkImg/hongmu/2/54_png.button.btn_right.png", 1, 10 + i);
                }
                dians[i].setBounds(281 + i % 2 * 13, 225 + i / 2 * 24, 13, 13);
                dians[i].addMouseListener(new PointChangeMouslisten(i));
                this.add(dians[i]);
            }
            Font font = new Font("楷体", Font.BOLD, 18);
            // 名字
            labrolename = new JLabel();
            labrolename.setBounds(190, 46, 120, 15);
            labrolename.setForeground(Color.PINK);
            labrolename.setFont(font);
            this.add(labrolename);
            font = new Font("仿宋", Font.BOLD, 16);
            // 角色Id
            labappeleid = new JLabel();
            labappeleid.setBounds(190, 71, 120, 15);
            labappeleid.setForeground(Color.orange);
            labappeleid.setFont(font);
            this.add(labappeleid);

            // 帮派
            labgangs = new JLabel();
            labgangs.setBounds(190, 95, 120, 15);
            labgangs.setForeground(Color.WHITE);
            labgangs.setFont(font);
            this.add(labgangs);

            // 声望
            labprestige = new JLabel();
            labprestige.setBounds(190, 119, 120, 15);
            labprestige.setForeground(Color.WHITE);
            labprestige.setFont(font);
            this.add(labprestige);

            // 战绩
            labrecord = new JLabel();
            labrecord.setBounds(190, 143, 120, 15);
            labrecord.setForeground(Color.WHITE);
            labrecord.setFont(font);
            this.add(labrecord);

            // 称谓
            labappellation = new JLabel();
            labappellation.setBounds(190, 165, 120, 18);
            labappellation.setForeground(Color.WHITE);
            labappellation.setFont(font);
            this.add(labappellation);

            // 种族
            labrace = new JLabel();
            labrace.setBounds(22, 165, 110, 15);
            labrace.setForeground(new Color(187, 165, 75));
            labrace.setFont(UIUtils.TEXT_HY17);
            labrace.setHorizontalAlignment(SwingConstants.CENTER);
            this.add(labrace);

            // 飞升等级
            labrisegrade = new JLabel();
            labrisegrade.setBounds(69, 154, 55, 15);
            labrisegrade.setForeground(Color.WHITE);
            labrisegrade.setFont(font);
            this.add(labrisegrade);

            // 级别
            labrolelevel = new JLabel();
            labrolelevel.setBounds(58, 202, 80, 15);
            labrolelevel.setForeground(Color.WHITE);
            labrolelevel.setFont(font);
            this.add(labrolelevel);

            // HP
            labHP = new JLabel();
            labHP.setBounds(58, 226, 125, 15);
            labHP.setForeground(Color.WHITE);
            labHP.setFont(font);
            this.add(labHP);

            // MP
            labMP = new JLabel();
            labMP.setBounds(58, 250, 125, 15);
            labMP.setForeground(Color.WHITE);
            labMP.setFont(font);
            this.add(labMP);

            // AP
            labAP = new JLabel();
            labAP.setBounds(58, 274, 125, 15);
            labAP.setForeground(Color.WHITE);
            labAP.setFont(font);
            this.add(labAP);

            // SP
            labSP = new JLabel();
            labSP.setBounds(58, 298, 125, 15);
            labSP.setForeground(Color.WHITE);
            labSP.setFont(font);
            this.add(labSP);

            // 禅定
            labCP = new JLabel();
            labCP.setBounds(58, 322, 125, 15);
            labCP.setForeground(Color.WHITE);
            labCP.setFont(font);
            this.add(labCP);

            // EXP
            labEXP = new JLabel();
            labEXP.setBounds(58, 345, 125, 15);
            labEXP.addMouseListener(new WLLMouslisten(30));
            labEXP.setForeground(Color.WHITE);
            labEXP.setFont(font);
            this.add(labEXP);

            // 根骨
            labrootbone = new JLabel();
            labrootbone.setBounds(243, 225, 61, 15);
            labrootbone.setForeground(Color.WHITE);
            labrootbone.setFont(font);
            this.add(labrootbone);

            // 灵性
            labintelligence = new JLabel();
            labintelligence.setBounds(243, 249, 61, 15);
            labintelligence.setForeground(Color.WHITE);
            labintelligence.setFont(font);
            this.add(labintelligence);

            // 力量
            labpower = new JLabel();
            labpower.setBounds(243, 273, 61, 15);
            labpower.setForeground(Color.WHITE);
            labpower.setFont(font);
            this.add(labpower);

            // 敏捷
            labspeed = new JLabel();
            labspeed.setBounds(243, 297, 61, 15);
            labspeed.setForeground(Color.WHITE);
            labspeed.setFont(font);
            this.add(labspeed);

            // 定力
            labability = new JLabel("0");
            labability.setBounds(243, 322, 61, 15);
            labability.setForeground(Color.WHITE);
            labability.setFont(font);
            this.add(labability);

            // 可分配点数
            labpointnumber = new JLabel();
            labpointnumber.setBounds(270, 202, 41, 15);
            labpointnumber.setForeground(Color.WHITE);
            labpointnumber.setFont(font);
            this.add(labpointnumber);

            // 人物头像框
            labroleheadFrame = new JLabel();
            labroleheadFrame.setBounds(36, 45, 87, 112);
            labroleheadFrame.setIcon(new
                    ImageIcon("inkImg/hongmu/soaring/头像框w87,h122px.png"));
            this.add(labroleheadFrame);

            // 人物头像
            labrolehead = new JLabel();
            labrolehead.setBounds(43, 45, 75, 112);
            this.add(labrolehead);
            // 初始化时加载保存的头像
            loadSavedAvatar();

            this.labroleheadBlack = new JLabel();
            this.labroleheadBlack.setBounds(36, 45, 87, 112);
            this.labroleheadBlack.setIcon(new ImageIcon("inkImg/hongmu/soaring/头像背景w87,h122px.png"));
            this.add(this.labroleheadBlack);

            // 添加头像切换按钮
            avatarSwitchBtn = new JpanelOnJalbelBtn("inkImg/background/qiehuantouxiang.png", 1, UIUtils.COLOR_WHITE2, 199, "", this);
            avatarSwitchBtn.setBounds(14, 39, 23, 122);

            avatarSwitchBtn.setOpaque(false);
            avatarSwitchBtn.setLayout(null);
            this.setComponentZOrder(avatarSwitchBtn, 0);
            this.add(avatarSwitchBtn);


            // 确认加点
            btnsure = new JpanelOnJalbelBtn("inkImg/hongmu/1/a20.png", 1, UIUtils.COLOR_BTNTEXT, 0, "", this);
            btnsure.setBounds(160, 345, 68, 17);
            this.add(btnsure);


            if (cbkg.equals("开")) {
                // 七十二变
                btnSevenTwo = new JpanelOnJalbelBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, 8, "七十二变", this);
                btnSevenTwo.setBounds(35 - 19, 372 + 10, 80, 26);
                this.add(btnSevenTwo);

                // 灵 宝
                btnmount = new JpanelOnJalbelBtn("inkImg/hongmu/1/60_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 1, "灵宝", this);
                btnmount.setBounds(130 - 19, 372 + 10, 60, 26);
                this.add(btnmount);
                // 角色抗性
                btnroleresistance = new JpanelOnJalbelBtn("inkImg/hongmu/1/60_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 2, "抗性", this);
                btnroleresistance.setBounds(205 - 19, 372 + 10, 60, 26);
                this.add(btnroleresistance);

                // 翅膀
                wingBtn = new JpanelOnJalbelBtn("inkImg/hongmu/1/60_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 9, "翅膀", this);
                wingBtn.setBounds(280 - 19, 372 + 10, 60, 26);
                this.add(wingBtn);

            } else {

                // 七十二变
                btnSevenTwo = new JpanelOnJalbelBtn("inkImg/hongmu/1/100_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 8, "七十二变", this);
                btnSevenTwo.setBounds(45 - 22, 372 + 10, 100, 26);
                this.add(btnSevenTwo);

                // 灵 宝
                btnmount = new JpanelOnJalbelBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, 1, "灵 宝", this);
                btnmount.setBounds(160 - 22, 372 + 10, 80, 26);
                this.add(btnmount);

                // 角色抗性
                btnroleresistance = new JpanelOnJalbelBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, 2, "抗 性", this);
                btnroleresistance.setBounds(255 - 22, 372 + 10, 80, 26);
                this.add(btnroleresistance);
            }

            if (configure.getXpgnkg().equals("开")) {
//
//
//                // 技能查看
                btndskills = new JpanelOnJalbelBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, 4, "人物技能", this);
                btndskills.setBounds(35 - 19, 405 + 10, 80, 26);
                this.add(btndskills);


                // 坐 骑
                btnset1 = new JpanelOnJalbelBtn("inkImg/hongmu/1/60_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 17, "坐骑", this);
                btnset1.setBounds(130 - 19, 405 + 10, 60, 26);
                this.add(btnset1);


                // 作 坊
                btnset = new JpanelOnJalbelBtn("inkImg/hongmu/1/60_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 7, "作坊", this);
                btnset.setBounds(205 - 19, 405 + 10, 60, 26);
                this.add(btnset);


                btnlock1 = new JpanelOnJalbelBtn("inkImg/hongmu/1/60_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 16, "星盘", this);
                btnlock1.setBounds(280 - 19, 405 + 10, 60, 26);
                this.add(btnlock1);

            } else {

                // 技能查看
                btndskills = new JpanelOnJalbelBtn("inkImg/hongmu/1/100_26.png", 1, UIUtils.COLOR_BTNPUTONG2, 4, "人物技能", this);
                btndskills.setBounds(45 - 22, 405 + 10, 100, 26);
                this.add(btndskills);


                // 坐 骑
                btnset1 = new JpanelOnJalbelBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, 17, "坐 骑", this);
                btnset1.setBounds(160 - 22, 405 + 10, 80, 26);
                this.add(btnset1);


                // 作 坊
                btnset = new JpanelOnJalbelBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, 7, "作 坊", this);
                btnset.setBounds(255 - 22, 405 + 10, 80, 26);
                this.add(btnset);


            }


            // 名字按钮
            nameBtn = new CharacterBtn("inkImg/hongmu/1/a19.png", 1, UIUtils.COLOR_BTNTEXT, "", 1);
            nameBtn.setBounds(148, 45, 34, 17);
            this.add(nameBtn);
            // id按钮
            idBtn = new CharacterBtn("inkImg/hongmu/1/a14.png", 1, UIUtils.COLOR_BTNTEXT, "", 2);
            idBtn.setBounds(148, 69, 34, 17);
            this.add(idBtn);
            // 称谓按钮
            labappellationBtn = new CharacterBtn("inkImg/hongmu/1/a15.png", 1, UIUtils.COLOR_BTNTEXT, "", 3);
            labappellationBtn.setBounds(148, 165, 34, 17);
            this.add(labappellationBtn);
            // 切换属性
            attributeBtn = new CharacterBtn("inkImg/hongmu/1/切属性w51,h51px.png", 1, UIUtils.COLOR_BTNTEXT, "", 4);
            attributeBtn.setBounds(140, 200, 51, 17);
            this.add(attributeBtn);

            // 转换
            transformationBtn = new CharacterBtn("inkImg/hongmu/1/a21.png", 1, UIUtils.COLOR_BTNTEXT, "", 5);
            transformationBtn.setBounds(189, 345, 34, 17);
            this.add(transformationBtn);
        }


    }

    private ImageIcon icon;

    // private ImageIcon icon2;
    private String style = MyIsif.getStyle();

    private ImageIcon sm_icon_less3 = new ImageIcon( "inkImg/newbackground/B101.png");

    private ImageIcon sm_icon_grate3 = new ImageIcon( "inkImg/newbackground/B102.png");

    private ImageIcon hm_icon_less3  = new ImageIcon("inkImg/hongmu/soaring/人物属性面板新（飞升前）w335,h477px.png");

    private ImageIcon hm_icon_grate3  =  new ImageIcon("inkImg/hongmu/soaring/人物属性面板新w335,h477px.png");

    // 添加AvatarSwitchFrame面板的引用
    private AvatarSwitchFrame avatarSwitchFramePanel;

    // 打开头像切换面板的方法
    private void openAvatarSwitchFrame() {
        System.out.println("尝试打开头像切换面板");
        try {
            // 使用FormsManagement来管理AvatarSwitchFrame，就像其他窗口一样
            FormsManagement.showForm(199); // 使用一个特殊的ID来显示面板
            System.out.println("头像切换面板已打开");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("打开头像切换面板时出错: " + e.getMessage());
        }
    }


    // 关闭头像切换面板的方法
    public void closeAvatarSwitchFrame() {
        System.out.println("关闭头像切换面板");
        if (avatarSwitchFramePanel != null) {
            remove(avatarSwitchFramePanel);
            avatarSwitchFramePanel = null;

            // 重新布局和刷新界面
            revalidate();
            repaint();

            System.out.println("头像切换面板已关闭");
        }
    }

    // 加载保存的头像
    private void loadSavedAvatar() {
        try {
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            if (login != null && login.getRole_id() != null && labrolehead != null) {
                // 使用角色ID作为文件名加载头像路径
                String roleId = login.getRole_id().toString();
                String currentSpeciesId = "1"; // 默认种族ID

                // 安全地获取当前种族ID
                if (login.getSpecies_id() != null) {
                    currentSpeciesId = login.getSpecies_id().toString();
                }

                Properties props = new Properties();
                // 修改配置文件路径到resource/other目录
                File file = new File("resource/other/avatar_" + roleId + ".properties");

                if (file.exists()) {
                    FileInputStream fis = new FileInputStream(file);
                    props.load(fis);
                    fis.close();

                    // 检查保存的种族ID是否与当前种族ID一致
                    String savedSpeciesId = props.getProperty("speciesId", "");

                    // 如果种族ID不一致，说明发生了转换
                    if (!savedSpeciesId.equals(currentSpeciesId)) {
                        // 更新种族ID
                        props.setProperty("speciesId", currentSpeciesId);
                        // 清除旧的头像路径，使用新种族默认头像
                        props.remove("avatarPath");

                        // 保存更新后的配置
                        FileOutputStream fos = new FileOutputStream(file);
                        props.store(fos, "Avatar configuration updated for role " + roleId);
                        fos.close();

                        // 使用新种族默认头像，保持原始尺寸以确保清晰度
                        ImageIcon defaultIcon = CutButtonImage.getImage("img/head/" + currentSpeciesId + ".png", -1, -1);
                        // 只在必要时缩放
                        if (defaultIcon.getIconWidth() > 0 && defaultIcon.getIconHeight() > 0) {
                            Image img = defaultIcon.getImage();
                            // 检查是否需要缩放
                            if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                                Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                                defaultIcon = new ImageIcon(scaledImg);
                            }
                        }
                        labrolehead.setIcon(defaultIcon);
                        try {
                            if (ZhuFrame.getZhuJpanel() != null) {
                                ZhuFrame.getZhuJpanel().updateRoleImg("img/head/" + currentSpeciesId + ".png");
                            }
                        } catch (Exception e) {
                            System.out.println("更新主界面头像时出现异常: " + e.getMessage());
                        }
                        return;
                    }

                    // 种族未变化，尝试加载自定义头像
                    String avatarPath = props.getProperty("avatarPath", "");
                    if (!avatarPath.isEmpty()) {
                        File avatarFile = new File(avatarPath);
                        if (avatarFile.exists()) {
                            ImageIcon icon = new ImageIcon(avatarPath);
                            // 保持原始尺寸以确保清晰度
                            if (icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
                                Image img = icon.getImage();
                                // 只在图片太大时才缩放，避免不必要的缩放导致模糊
                                if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                                    Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                                    icon = new ImageIcon(scaledImg);
                                }
                            }
                            labrolehead.setIcon(icon);
                            // 同时更新主界面头像
                            try {
                                if (ZhuFrame.getZhuJpanel() != null) {
                                    ZhuFrame.getZhuJpanel().updateRoleImg(avatarPath);
                                }
                            } catch (Exception e) {
                                // 忽略更新主界面头像时可能出现的异常
                                System.out.println("更新主界面头像时出现异常: " + e.getMessage());
                            }
                        } else {
                            // 自定义头像文件不存在，使用默认头像
                            ImageIcon defaultIcon = CutButtonImage.getImage("img/head/" + currentSpeciesId + ".png", -1, -1);
                            if (defaultIcon.getIconWidth() > 0 && defaultIcon.getIconHeight() > 0) {
                                Image img = defaultIcon.getImage();
                                if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                                    Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                                    defaultIcon = new ImageIcon(scaledImg);
                                }
                            }
                            labrolehead.setIcon(defaultIcon);
                            try {
                                if (ZhuFrame.getZhuJpanel() != null) {
                                    ZhuFrame.getZhuJpanel().updateRoleImg("img/head/" + currentSpeciesId + ".png");
                                }
                            } catch (Exception e) {
                                System.out.println("更新主界面头像时出现异常: " + e.getMessage());
                            }

                            // 从配置中移除不存在的头像路径
                            props.remove("avatarPath");
                            FileOutputStream fos = new FileOutputStream(file);
                            props.store(fos, "Avatar configuration updated for role " + roleId);
                            fos.close();
                        }
                    } else {
                        // 没有自定义头像，使用默认头像
                        ImageIcon defaultIcon = CutButtonImage.getImage("img/head/" + currentSpeciesId + ".png", -1, -1);
                        if (defaultIcon.getIconWidth() > 0 && defaultIcon.getIconHeight() > 0) {
                            Image img = defaultIcon.getImage();
                            if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                                Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                                defaultIcon = new ImageIcon(scaledImg);
                            }
                        }
                        labrolehead.setIcon(defaultIcon);
                        try {
                            if (ZhuFrame.getZhuJpanel() != null) {
                                ZhuFrame.getZhuJpanel().updateRoleImg("img/head/" + currentSpeciesId + ".png");
                            }
                        } catch (Exception e) {
                            System.out.println("更新主界面头像时出现异常: " + e.getMessage());
                        }
                    }
                } else {
                    // 配置文件不存在，创建新配置文件并使用默认头像
                    props.setProperty("speciesId", currentSpeciesId);
                    // 修改配置文件路径到resource/other目录
                    File directory = new File("resource/other");
                    if (!directory.exists()) {
                        directory.mkdirs();
                    }
                    FileOutputStream fos = new FileOutputStream(new File("resource/other/avatar_" + roleId + ".properties"));
                    props.store(fos, "Avatar configuration for role " + roleId);
                    fos.close();

                    ImageIcon defaultIcon = CutButtonImage.getImage("img/head/" + currentSpeciesId + ".png", -1, -1);
                    if (defaultIcon.getIconWidth() > 0 && defaultIcon.getIconHeight() > 0) {
                        Image img = defaultIcon.getImage();
                        if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                            Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                            defaultIcon = new ImageIcon(scaledImg);
                        }
                    }
                    labrolehead.setIcon(defaultIcon);
                    try {
                        if (ZhuFrame.getZhuJpanel() != null) {
                            ZhuFrame.getZhuJpanel().updateRoleImg("img/head/" + currentSpeciesId + ".png");
                        }
                    } catch (Exception e) {
                        System.out.println("更新主界面头像时出现异常: " + e.getMessage());
                    }
                }
            } else if (labrolehead != null) {
                // login为null或roleId为null时使用默认头像
                try {
                    ImageIcon defaultIcon = CutButtonImage.getImage("img/head/1.png", -1, -1);
                    if (defaultIcon.getIconWidth() > 0 && defaultIcon.getIconHeight() > 0) {
                        Image img = defaultIcon.getImage();
                        if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                            Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                            defaultIcon = new ImageIcon(scaledImg);
                        }
                    }
                    labrolehead.setIcon(defaultIcon);
                    if (ZhuFrame.getZhuJpanel() != null) {
                        ZhuFrame.getZhuJpanel().updateRoleImg("img/head/1.png");
                    }
                } catch (Exception e) {
                    System.out.println("加载默认头像时出现异常: " + e.getMessage());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            // 出现异常时使用默认头像
            try {
                if (labrolehead != null) {
                    ImageIcon defaultIcon = CutButtonImage.getImage("img/head/1.png", -1, -1);
                    if (defaultIcon.getIconWidth() > 0 && defaultIcon.getIconHeight() > 0) {
                        Image img = defaultIcon.getImage();
                        if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                            Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                            defaultIcon = new ImageIcon(scaledImg);
                        }
                    }
                    labrolehead.setIcon(defaultIcon);
                }
                if (ZhuFrame.getZhuJpanel() != null) {
                    ZhuFrame.getZhuJpanel().updateRoleImg("img/head/1.png");
                }
            } catch (Exception ex) {
                System.out.println("加载默认头像时出现异常: " + ex.getMessage());
            }
        }
    }
    // 更新头像显示的方法
    public void updateAvatar(String avatarPath) {
        try {
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            if (login != null && labrolehead != null) {
                // 更新面板中的头像
                ImageIcon icon = new ImageIcon(avatarPath);
                // 保持原始尺寸以确保清晰度
                if (icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
                    Image img = icon.getImage();
                    // 只在图片太大时才缩放，避免不必要的缩放导致模糊
                    if (img.getWidth(null) > 75 || img.getHeight(null) > 100) {
                        Image scaledImg = img.getScaledInstance(75, 100, Image.SCALE_SMOOTH);
                        icon = new ImageIcon(scaledImg);
                    }
                }
                labrolehead.setIcon(icon);

                // 同时更新主界面头像
                try {
                    if (ZhuFrame.getZhuJpanel() != null) {
                        ZhuFrame.getZhuJpanel().updateRoleImg(avatarPath);
                    }
                } catch (Exception e) {
                    System.out.println("更新主界面头像时出现异常: " + e.getMessage());
                }

                // 保存头像路径到本地文件
                try {
                    // 使用角色ID作为文件名保存头像路径
                    String roleId = login.getRole_id().toString();
                    Properties props = new Properties();
                    // 修改配置文件路径到resource/other目录
                    File directory = new File("resource/other");
                    if (!directory.exists()) {
                        directory.mkdirs();
                    }
                    File file = new File("resource/other/avatar_" + roleId + ".properties");
                    if (file.exists()) {
                        FileInputStream fis = new FileInputStream(file);
                        props.load(fis);
                        fis.close();
                    } else {
                        // 如果配置文件不存在，初始化种族ID
                        if (login.getSpecies_id() != null) {
                            props.setProperty("speciesId", login.getSpecies_id().toString());
                        }
                    }
                    props.setProperty("avatarPath", avatarPath);
                    FileOutputStream fos = new FileOutputStream(file);
                    props.store(fos, "Avatar Path for role " + roleId);
                    fos.close();

                    // 发送网络请求更新服务器端的头像信息
                    String message = "AvatarChange#" + avatarPath;
                    org.come.socket.SendMessageUntil.toServer(message);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // 每次重绘时都重新加载保存的头像，确保显示正确
        loadSavedAvatar();
//        无点可加后隐藏加点图标以及确认加点
        final LoginResult login = RoleData.getRoleData().getLoginResult();
        this.labEXP.setText(login.getExperience().toString());
        if (login.getCanpoint().intValue() == 0) {
            int i = 0;
            while (i < this.dians.length) {
                if (login.getGrade().intValue() <= 3) {
                    this.dians[8].setVisible(false);
                    this.dians[9].setVisible(false);
                }
                this.dians[i].setVisible(false);
                ++i;
            }
            this.btnsure.setVisible(false);
        } else {
            int i = 0;
            while (i < this.dians.length) {
                if (login.getGrade().intValue() <= 3) {
                    this.dians[8].setVisible(false);
                    this.dians[9].setVisible(false);
                } else {
                    this.dians[0].setVisible(true);
                    this.dians[1].setVisible(true);
                    this.dians[2].setVisible(true);
                    this.dians[3].setVisible(true);
                    this.dians[4].setVisible(true);
                    this.dians[5].setVisible(true);
                    this.dians[6].setVisible(true);
                    this.dians[7].setVisible(true);
                }
                ++i;
            }
            this.btnsure.setVisible(true);
        }

        if (MyIsif.getStyle().equals("水墨UI")) {
            if (level <= 3) {
                g.drawImage(sm_icon_less3.getImage(), 0, 0, 359, 450, this);
            } else {
                g.drawImage(sm_icon_grate3.getImage(), 0, 0, 359, 450, this);
            }
            //靓号
            String num = login.getLiangHao();
            if (StringUtils.isNotEmpty(num)) {
                String[] nums = num.split("");
                String type = String.valueOf(login.getLianghaotype());
                for (int i = 0; i < nums.length; i++) {
                    int xnum = 213 + (12 * i);
                    g.drawImage(CutButtonImage.getImage("inkImg/number/" + type + nums[i] + ".png", 11, 15).getImage(), xnum, 56, 11, 15, this);
                }
            }
        } else {
            if (level <= 3) {
                g.drawImage(this.hm_icon_less3.getImage(), 0, 0, 335, 477, this);
            } else {
                g.drawImage(this.hm_icon_grate3.getImage(), 0, 0, 335, 477, this);
            }
            String num = login.getLiangHao();
            if (StringUtils.isNotEmpty(num)) {
                String[] nums = num.split("");
                String type = String.valueOf(login.getLianghaotype());
                for (int i = 0; i < nums.length; i++) {
                    int xnum = 188 + (12 * i);
                    g.drawImage(CutButtonImage.getImage("inkImg/number/" + type + nums[i] + ".png", 11, 15).getImage(), xnum, 70, 11, 15, this);
                }
            }
        }
    }

    /**
     * 0-4 获取根骨灵性力量敏捷可分配点
     */
    public int getdian(int type) {
        try {
            if (type == 0) {
                type = Integer.parseInt(labrootbone.getText());
            } else if (type == 1) {
                type = Integer.parseInt(labintelligence.getText());
            } else if (type == 2) {
                type = Integer.parseInt(labpower.getText());
            } else if (type == 3) {
                type = Integer.parseInt(labspeed.getText());
            } else if (type == 4) {
                type = Integer.parseInt(labability.getText());
            } else if (type == 5) {
                type = Integer.parseInt(labpointnumber.getText());
            }
        } catch (Exception e) {
            // TODO: handle exception
            type = 0;
        }
        return type;
    }

    /**
     * 0-4 点数变化根骨灵性力量敏捷可分配点
     */
    public void adddian(int type, int point) {
        try {
            if (type == 0) {
                type = Integer.parseInt(labrootbone.getText());
                labrootbone.setText(type + point + "");
            } else if (type == 1) {
                type = Integer.parseInt(labintelligence.getText());
                labintelligence.setText(type + point + "");
            } else if (type == 2) {
                type = Integer.parseInt(labpower.getText());
                labpower.setText(type + point + "");
            } else if (type == 3) {
                type = Integer.parseInt(labspeed.getText());
                labspeed.setText(type + point + "");
            } else if (type == 4) {
                type = Integer.parseInt(labability.getText());
                labability.setText(type + point + "");
            }
            type = Integer.parseInt(labpointnumber.getText());
            labpointnumber.setText(type - point + "");
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

    /**
     * 飞升前面板与飞升后面板切换
     *
     * @param lvltrue <=3没有飞升 >3飞升
     */
    public void changeSoaringPanel(int lvltrue) {
        level = lvltrue;
        if (lvltrue <= 3) {// 没有飞升
            // 隐藏飞升后才有的功能
            transformationBtn.setVisible(false);
            dians[8].setVisible(false);
            dians[9].setVisible(false);
            labability.setVisible(false);
            labCP.setVisible(false);
            if (MyIsif.getStyle().equals("水墨UI")) {
                labEXP.setBounds(80, 308, 125, 15);
                icon = CutButtonImage.getImage("inkImg/newbackground/B101.png", -1, -1);
                btnsure.setBounds(279, 309, 68, 17);
            } else {
                labEXP.setBounds(58, 322, 125, 15);
                icon = CutButtonImage.getImage("inkImg/hongmu/soaring/人物属性面板新（飞升前）w335,h477px.png", -1, -1);
                btnsure.setBounds(239, 322, 68, 17);

            }

        } else {// 飞升
            // 展示飞升才有的功能
            transformationBtn.setVisible(true);
            dians[8].setVisible(true);
            dians[9].setVisible(true);
            labability.setVisible(true);
            labCP.setVisible(true);
            if (MyIsif.getStyle().equals("水墨UI")) {
                labEXP.setBounds(80, 332, 125, 15);
                icon = CutButtonImage.getImage( "inkImg/newbackground/B102.png", -1, -1);
                btnsure.setBounds(279, 333, 68, 17);
            } else {
                labEXP.setBounds(58, 345, 125, 15);
                icon = CutButtonImage.getImage("inkImg/hongmu/soaring/人物属性面板新w335,h477px.png", -1, -1);
                btnsure.setBounds(239, 345, 68, 17);
            }

        }
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if (e.getSource() instanceof JpanelOnJalbelBtn) {
            JpanelOnJalbelBtn btn = (JpanelOnJalbelBtn) e.getSource();
            switch (btn.getType()) {
                case 199: // 头像切换按钮
                    System.out.println("点击了头像切换按钮");
                    openAvatarSwitchFrame();
                    ZhuFrame.getZhuJpanel().settingsMenu(true,1);
                    Music.addyinxiao("开关窗口.mp3");
                    break;
                // ... 其他按钮的处理
            }
        }
        // ... 其他鼠标点击处理
    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        FormsManagement.HideForm(0);
    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    public Teststatejframe getTeststatejframe() {
        return teststatejframe;
    }

    public void setTeststatejframe(Teststatejframe teststatejframe) {
        this.teststatejframe = teststatejframe;
    }

    public JLabel getLabel() {
        return label;
    }

    public void setLabel(JLabel label) {
        this.label = label;
    }

    public JLabel getLabrolename() {
        return labrolename;
    }

    public void setLabrolename(JLabel labrolename) {
        this.labrolename = labrolename;
    }

    public JLabel getLabappellation() {
        return labappellation;
    }

    public void setLabappellation(JLabel labappellation) {
        this.labappellation = labappellation;
    }

    public JLabel getLabrace() {
        return labrace;
    }

    public void setLabrace(JLabel labrace) {
        this.labrace = labrace;
    }

    public JLabel getLabgangs() {
        return labgangs;
    }

    public void setLabgangs(JLabel labgangs) {
        this.labgangs = labgangs;
    }

    public JLabel getLabprestige() {
        return labprestige;
    }

    public void setLabprestige(JLabel labprestige) {
        this.labprestige = labprestige;
    }

    public JLabel getLabrecord() {
        return labrecord;
    }

    public void setLabrecord(JLabel labrecord) {
        this.labrecord = labrecord;
    }

    public JLabel getLabrolelevel() {
        return labrolelevel;
    }

    public void setLabrolelevel(JLabel labrolelevel) {
        this.labrolelevel = labrolelevel;
    }

    public JLabel getLabHP() {
        return labHP;
    }

    public void setLabHP(JLabel labHP) {
        this.labHP = labHP;
    }

    public JLabel getLabMP() {
        return labMP;
    }

    public void setLabMP(JLabel labMP) {
        this.labMP = labMP;
    }

    public JLabel getLabAP() {
        return labAP;
    }

    public void setLabAP(JLabel labAP) {
        this.labAP = labAP;
    }

    public JLabel getLabSP() {
        return labSP;
    }

    public void setLabSP(JLabel labSP) {
        this.labSP = labSP;
    }

    public JLabel getLabEXP() {
        return labEXP;
    }

    public void setLabEXP(JLabel labEXP) {
        this.labEXP = labEXP;
    }

    public JLabel getLabrootbone() {
        return labrootbone;
    }

    public void setLabrootbone(JLabel labrootbone) {
        this.labrootbone = labrootbone;
    }

    public JLabel getLabintelligence() {
        return labintelligence;
    }

    public void setLabintelligence(JLabel labintelligence) {
        this.labintelligence = labintelligence;
    }

    public JLabel getLabpower() {
        return labpower;
    }

    public void setLabpower(JLabel labpower) {
        this.labpower = labpower;
    }

    public JLabel getLabspeed() {
        return labspeed;
    }

    public void setLabspeed(JLabel labspeed) {
        this.labspeed = labspeed;
    }

    public JLabel getLabpointnumber() {
        return labpointnumber;
    }

    public void setLabpointnumber(JLabel labpointnumber) {
        this.labpointnumber = labpointnumber;
    }

    public int getExpsize() {
        return expsize;
    }

    public void setExpsize(int expsize) {
        this.expsize = expsize;
    }

    public JLabel getLabrisegrade() {
        return labrisegrade;
    }

    public void setLabrisegrade(JLabel labrisegrade) {
        this.labrisegrade = labrisegrade;
    }

    public JLabel getLabrolehead() {
        return labrolehead;
    }

    public void setLabrolehead(JLabel labrolehead) {
        this.labrolehead = labrolehead;
    }

    public JLabel getLabappeleid() {
        return labappeleid;
    }

    public void setLabappeleid(JLabel labappeleid) {
        this.labappeleid = labappeleid;
    }

    public JLabel getLabCP() {
        return labCP;
    }

    public void setLabCP(JLabel labCP) {
        this.labCP = labCP;
    }

    public JLabel getLabability() {
        return labability;
    }

    public void setLabability(JLabel labability) {
        this.labability = labability;
    }

    public JpanelOnJalbelBtn getBtnmount() {
        return btnmount;
    }

    public void setBtnmount(JpanelOnJalbelBtn btnmount) {
        this.btnmount = btnmount;
    }

    public JpanelOnJalbelBtn getBtnsure() {
        return btnsure;
    }

    public void setBtnsure(JpanelOnJalbelBtn btnsure) {
        this.btnsure = btnsure;
    }

    public JpanelOnJalbelBtn getBtnroleresistance() {
        return btnroleresistance;
    }

    public void setBtnroleresistance(JpanelOnJalbelBtn btnroleresistance) {
        this.btnroleresistance = btnroleresistance;
    }

    public JpanelOnJalbelBtn getBtndskills() {
        return btndskills;
    }

    public void setBtndskills(JpanelOnJalbelBtn btndskills) {
        this.btndskills = btndskills;
    }

    public JpanelOnJalbelBtn getBtnstall() {
        return btnstall;
    }

    public void setBtnstall(JpanelOnJalbelBtn btnstall) {
        this.btnstall = btnstall;
    }

    public JpanelOnJalbelBtn getBtnset() {
        return btnset;
    }

    public void setBtnset(JpanelOnJalbelBtn btnset) {
        this.btnset = btnset;
    }

    public CharacterBtn getNameBtn() {
        return nameBtn;
    }

    public void setNameBtn(CharacterBtn nameBtn) {
        this.nameBtn = nameBtn;
    }

    public CharacterBtn getIdBtn() {
        return idBtn;
    }

    public void setIdBtn(CharacterBtn idBtn) {
        this.idBtn = idBtn;
    }

    public CharacterBtn getLabappellationBtn() {
        return labappellationBtn;
    }

    public void setLabappellationBtn(CharacterBtn labappellationBtn) {
        this.labappellationBtn = labappellationBtn;
    }

    public CharacterBtn getAttributeBtn() {
        return attributeBtn;
    }

    public void setAttributeBtn(CharacterBtn attributeBtn) {
        this.attributeBtn = attributeBtn;
    }

    public CharacterBtn getTransformationBtn() {
        return transformationBtn;
    }

    public void setTransformationBtn(CharacterBtn transformationBtn) {
        this.transformationBtn = transformationBtn;
    }

    public CharacterBtn[] getDians() {
        return dians;
    }

    public void setDians(CharacterBtn[] dians) {
        this.dians = dians;
    }

    public SpecificBtn getBtnXxzb() {
        return btnXxzb;
    }

    public void setBtnXxzb(SpecificBtn btnXxzb) {
        this.btnXxzb = btnXxzb;
    }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    // public ImageIcon getIcon2() {
    // return icon2;
    // }
    //
    // public void setIcon2(ImageIcon icon2) {
    // this.icon2 = icon2;
    // }

    public long getSerialversionuid() {
        return serialVersionUID;
    }

    public JpanelOnJalbelBtn getWingBtn() {
        return wingBtn;
    }

    public void setWingBtn(JpanelOnJalbelBtn wingBtn) {
        this.wingBtn = wingBtn;
    }

    public JpanelOnJalbelBtn getAvatarSwitchBtn() {
        return avatarSwitchBtn;
    }

    public void setAvatarSwitchBtn(JpanelOnJalbelBtn avatarSwitchBtn) {
        this.avatarSwitchBtn = avatarSwitchBtn;
    }

    public JLabel getLabEXPImg() {
        return labEXPImg;
    }

    public void setLabEXPImg(JLabel labEXPImg) {
        this.labEXPImg = labEXPImg;
    }

    public void showLabEXPImg(String curr, String max, int lvltrue) {
        this.remove(labEXPImg);
        int tmpy = lvltrue <= 3 ? 0 : 25;
        if (Xy2Util.interfaceConfig == 1) {
            tmpy = lvltrue <= 3 ? 0 : 23;
            labEXPImg = new JLabel();
            ImageIcon imageIcon = new ImageIcon("inkImg/hongmu/2/经验_条_102,h8.png");
            Image scaledInstance = imageIcon.getImage().getScaledInstance(125, 14, 10);
            imageIcon.setImage(scaledInstance);
            labEXPImg.setIcon(imageIcon);
            this.add(labEXPImg);
            double mul = Arith.mul(Arith.div(Double.parseDouble(curr), Double.parseDouble(max)), 125);
            Teststatejframe.getTeststatejframe().getTeststateJpanel().getLabEXPImg().setBounds(58, 301 + tmpy, (int) mul, 20);
        } else if (Xy2Util.interfaceConfig == 2) {
            labEXPImg = new JLabel();
            ImageIcon imageIcon = new ImageIcon("inkImg/hongmu/2/经验_条_102,h8.png");
            Image scaledInstance = imageIcon.getImage().getScaledInstance(130, 16, 10);
            imageIcon.setImage(scaledInstance);
            labEXPImg.setIcon(imageIcon);
            this.add(labEXPImg);
            double mul = Arith.mul(Arith.div(Double.parseDouble(curr), Double.parseDouble(max)), 130);
            labEXPImg.setBounds(80, 308 + tmpy, (int) mul, 16);
        } else if (Xy2Util.interfaceConfig == 3) {
            labEXPImg = new JLabel();
            ImageIcon imageIcon = new ImageIcon("inkImg/hongmu/2/经验_条_102,h8.png");
            Image scaledInstance = imageIcon.getImage().getScaledInstance(128, 16, 10);
            imageIcon.setImage(scaledInstance);
            labEXPImg.setIcon(imageIcon);
            this.add(labEXPImg);
            double mul = Arith.mul(Arith.div(Double.parseDouble(curr), Double.parseDouble(max)), 128);
            labEXPImg.setBounds(58, 322 + tmpy, (int) mul, 16);
        }
    }

}
